home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: April, 1997
- // Author: Carol Levy
- //
- // Description:
- // This script contains code to connect fields/emitters/
- // collisions to objects.
- // performDynamicsConnect is called when a user selects
- // a Connect menu item.
- //
- // Input Arguments to performDynamics():
- // int $whichConnection -- 1 = field; 2 = emitter; 3 = collision
- //
- // Return Value:
- // None.
- //
- //
- // ========== performDynamicsConnect ==========
- //
- // SYNOPSIS
- // Issue the appropriate connectDynamic command.
- //
- global proc performDynamicsConnect( int $whichConnection)
- {
- string $selected[] = `ls -sl`;
- string $cmd;
- int $i;
- string $cmdStart = "connectDynamic";
- int $len = size($selected);
- int $numConnections = $len - 1;
-
- if ($numConnections < 1)
- {
- string $theMsg;
- string $theType;
- switch ($whichConnection)
- {
- case 1: {
- $theType = "field";
-
- break;
- }
- case 2: {
- $theType = "emitter";
- break;
- }
- case 3: {
- $theType = "collision";
- break;
- }
- }
-
- if ($numConnections == -1)
- {
- $theMsg = "Nothing has been selected; ";
- }
- else if ($numConnections == 0)
- {
- $theMsg = "Only one object has been selected; ";
- }
- warning($theMsg + "select first the objects to be connected then the "+$theType);
- return;
- }
-
- // Create the command args for the selected command, and
- // issue the command.
- //
- switch ($whichConnection)
- {
- case 1: {
- string $field, $objects;
- string $fields[] = `ls -sl -typ field`;
- int $numFields = size($fields);
- if($numFields > 0) {
- for ($i = 0; $i < $len; $i++) {
- string $isField[] = `ls -type field $selected[$i]`;
- if (0 == size($isField)) {
- $objects += (" " + $selected[$i]);
- }
- }
- for ($field in $fields) {
- $cmd += ($cmdStart + " -f " + $field + $objects +"; ");
- $cmd += "; ";
- }
- } else {
- // if there's no dull normal fields selected...
- // see if there's any fluids - and use them as fields instead
- string $fluids[];
- int $numFluids = 0;
- for ($i = 0; $i < $len; $i++) {
- string $fluidName = getFluidShape($selected[$i]);
- if (0 == size($fluidName)) {
- $objects += (" " + $selected[$i]);
- } else {
- $fluids[$numFluids++] = $fluidName;
- }
- }
- for ($fluid in $fluids) {
- $cmd += ($cmdStart + " -f " + $fluid + $objects +"; ");
- $cmd += "; ";
- }
-
- }
- break;
- }
- case 2:
-
- $cmd = $cmdStart + " -em " + $selected[$numConnections];
- break;
-
- case 3:
- // Collision. Must check whether last two
- // objects in selection list are the two parts of a
- // soft body. If so, use the geometry's name (which
- // will be second to last in list). The particle shape
- // will be last.
- //
- string $softQuery = "soft -q " + $selected[$len-1] +
- " " + $selected[$len-2];
- int $leadIsSoft = eval( $softQuery );
- if ($leadIsSoft)
- {
- $numConnections = $numConnections - 1;
- }
- $cmd = $cmdStart + " -c " + $selected[$numConnections];
- break;
- }
-
- if ($whichConnection != 1) {
- for ($i = 0; $i < $numConnections; $i++)
- {
- $cmd = $cmd + " " + $selected[$i];
- }
- }
- evalEcho ($cmd);
- }
-
-